<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const reg1 = /123/;
        reg1[Symbol.match] = function(val) {
            if(val.length = 3) {
                return val;
            }
            return 12323;
        };
        // console.log('123223'.match(reg1));
        let hasLengthOf10 = {
            [Symbol.match]: function (value) {
                return value.length === 10 ? [value] : null
            }
        };
        console.log('abcdefghij'.match(hasLengthOf10)); // [abcdefghij]
        console.log('abcdefghi'.match(hasLengthOf10)); // null
    </script>
</body>
</html>